/**
 * 
 */
package br.com.lazyprogrammer.social.infestit.util;

import org.json.JSONObject;

import br.com.lazyprogrammer.social.infestit.network.JSONConstants;
import br.com.lazyprogrammer.social.infestit.network.model.User;

/**
 * 
 * @author Limao Games <br />
 * <b>Email:</b> andreikeda@limaogames.com.br <br />
 * created on: 07/05/2014
 * @version 1.0
 * @see 
 */
public class Parser {
	
	public Parser() {
		
	}
	
	public int parseResponse(JSONObject parent) {
		return (parent.optInt(JSONConstants.STATUS));
	}

    public User parseUser(JSONObject jsonUser) {
        User user = null;
        user	= new User(jsonUser.optString(JSONConstants.ID));
        user.setUsername(jsonUser.optString(JSONConstants.USERNAME));
        user.setActive(jsonUser.optInt(JSONConstants.ACTIVE));
        user.setDescription(jsonUser.optString(JSONConstants.DESCRIPTION));
        user.setKey(jsonUser.optString(JSONConstants.KEY));
        user.setOnline(jsonUser.optInt(JSONConstants.ONLINE));
        user.setFirstName(jsonUser.optString(JSONConstants.FIRST_NAME));
        user.setLastName(jsonUser.optString(JSONConstants.LAST_NAME));
        user.setGoodDeed(jsonUser.optLong(JSONConstants.GOOD_DEED));
        user.setBadDeed(jsonUser.optLong(JSONConstants.BAD_DEED));
        user.setLevel(jsonUser.optInt(JSONConstants.LEVEL));
        user.setXP(jsonUser.optInt(JSONConstants.XP));
        return user;
    }

}
